#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<string> summaryRanges(vector<int>& nums) {
    int len = nums.size();
    int i = 0;
    vector<string> res;
    while(i < len) {
        int start = nums[i];
        ++i;
        while(i < len && nums[i] == nums[i-1]+1) {
            ++i;
        }
        int end = nums[i-1];
        string s = to_string(start);
        if(start != end) {
            s.append("->");
            s.append(to_string(end));
        }
        res.push_back(move(s));
    }
    return res;
}